# Resolve react_native_pods.rb with node to allow for hoisting
# require Pod::Executable.execute_command('node', ['-p',
#   'require.resolve(
#     "react-native/scripts/react_native_pods.rb",
#     {paths: [process.argv[1]]},
#   )', __dir__]).strip
$FirebaseSDKVersion = '11.9.0'

 def node_require(script)
   require Pod::Executable.execute_command('node', ['-p',
     "require.resolve(
       '#{script}',
       {paths: [process.argv[1]]},
     )", __dir__]).strip
 end
node_require('react-native/scripts/react_native_pods.rb')
node_require('react-native-permissions/scripts/setup.rb')

platform :ios, min_ios_version_supported
prepare_react_native_project!

setup_permissions([
  'AppTrackingTransparency',
  'BluetoothPeripheral',
  # 'Bluetooth',
  'Camera',
  'LocationAccuracy',
  'LocationAlways',
  'LocationWhenInUse',
  'Notifications',
  'PhotoLibrary',
  'PhotoLibraryAddOnly',
  # 'Calendars',
  # 'CalendarsWriteOnly',
  # 'Contacts',
  # 'FaceID',
  # 'MediaLibrary',
  'Microphone',
  # 'Motion',
  # 'Reminders',
  # 'Siri',
  # 'SpeechRecognition',
  # 'StoreKit',
])
# use_modular_headers!
use_frameworks! :linkage => :static  # ✅ 这样修改

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  # use_frameworks! :linkage => linkage.to_sym
  # use_frameworks! :linkage => :static
  # $RNFirebaseAsStaticFramework = true

end

target 'bjyWristech' do
  pod "react-native-nordic-dfu", path: "../node_modules/react-native-nordic-dfu"

  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  target 'bjyWristechTests' do
    inherit! :complete

    # Pods for testing
  end

  post_install do |installer|
    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false,
      # :ccache_enabled => true
    )
        #  添加这段，M1/M2 模拟器能跑起来，wechat 小而美！
    installer.pods_project.build_configurations.each do |config| config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
    end
  end
   pod 'WechatOpenSDK'
end
